﻿@page
@model IndexModel
@{
    ViewData["Title"] = "Home page";
}
<h2>Simple Feed Reader</h2>
<hr />
<div class="row">
    <div>
        <form method="get">
            <div class="form-group">
                <label>
                    Enter a feed URL:
                    <input name="FeedUrl" id="FeedUrl" class="form-control" value="@Request.Query["feedurl"]" />
                </label>
            </div>
            <div class="form-group">
                <input type="submit" value="Retrieve Feed" class="btn btn-default" />
            </div>
        </form>
    </div>
    
    @if (!string.IsNullOrEmpty(Model.ErrorText))
    {
        <div>
            <h3 class="text-danger">@Model.ErrorText</h3>
        </div>
    }

    @if (Model.NewsItems?.Count > 0)
    {
    <table class="table">
        <thead>
            <tr>
                <th>Title</th>
                <th>Published</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.NewsItems)
            {
                <tr>
                    <td>
                        <a href="@item.Uri" target="_blank">@item.Title</a>
                    </td>
                    <td>
                        @item.Published.ToString("MMM dd, yyyy HH:mm:ss")
                    </td>
                </tr>
            }
        </tbody>
    </table>
    }
</div>
